package com.example.location.interceptor;

import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class MyInterceptor implements HandlerInterceptor{
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        if(request.getSession().getAttribute("user")==null){
            request.setAttribute("msg","没有权限请先登录");
            response.sendRedirect(request.getContextPath()+"/login.html");
        }
        return HandlerInterceptor.super.preHandle(request, response, handler);
        }

}
